package com.kly.user.db.dao.impl;
import com.fqgj.common.base.AbstractBaseMapper;
import com.google.common.collect.Maps;
import com.kly.user.db.dao.UserBehaviorLogDao;
import com.kly.user.db.entity.UserBehaviorLogEntity;
import com.kly.user.enums.LogActionEnum;
import org.springframework.stereotype.Repository;

import java.util.Map;

/**
* User: linqu
* Date: 2023-06-02
* Time: 17:43:22.530
*/

@Repository
public class UserBehaviorLogDaoImpl extends AbstractBaseMapper<UserBehaviorLogEntity> implements UserBehaviorLogDao {

    /**
     * 查找用户最近一次操作记录
     */
    @Override
    public UserBehaviorLogEntity queryLatestLog(String userCode, Integer opType) {

        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("actionType", opType);
        return this.getSqlSession().selectOne(this.getStatement("queryLatestLog"), params);

    }

    @Override
    public UserBehaviorLogEntity getTodayFirstRecord(String userCode, Integer type) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("actionType", type);
        return this.getSqlSession().selectOne(this.getStatement("getTodayFirstRecord"), params);
    }
}